package com.jinzhi.jzweb.controller;

import com.jinzhi.jzweb.domain.vo.JazUserOrderVO;
import com.jinzhi.jzweb.service.JazUserOrderService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@Controller
@RequestMapping("/jzweb")
public class JazServiceListController {
    @Autowired
    private JazUserOrderService jazUserOrderService;
    @GetMapping("/serviceList")
    @RequiresPermissions("jzweb:serviceList:serviceList")
    String JazGroupSpecs(){
        return "jzweb/serviceList/index";
    }

    @GetMapping("/detailOfIncomeAndExpenditure")
    @RequiresPermissions("jzweb:detailOfIncomeAndExpenditure:list")
    String DetailOfIncomeAndExpenditure(){
        return "jzweb/detailOfIncomeAndExpenditure/index";
    }

    @GetMapping("/serviceList/info/{id}/{type}")
    String JazGroupSpecsInfo(@PathVariable("id") Long id,@PathVariable("type") String type,Model model){
        JazUserOrderVO jazUserOrderVO;
        if("transferor".equals(type)){
            jazUserOrderVO = (JazUserOrderVO) jazUserOrderService.serviceTransferById(id).getData();
        }else{
            jazUserOrderVO = jazUserOrderService.selectOrderDetail(id);
        }
        String beforePicture=jazUserOrderVO.getBeforePicture();
        String afterPicture=jazUserOrderVO.getAfterPicture();
        model.addAttribute("beforePictureList",null==beforePicture||beforePicture==""?new ArrayList<>():beforePicture.split(","));
        model.addAttribute("afterPictureList",null==afterPicture||afterPicture==""?new ArrayList<>():afterPicture.split(","));


        model.addAttribute("myData", jazUserOrderVO);
        model.addAttribute("id", id);
        model.addAttribute("type", type);



        return "jzweb/serviceList/info";
    }
}




